package com.chixing.day12_date_factory.word;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.chrono.ChronoLocalDateTime;
import java.util.ArrayList;

public class OrderTest {
    public static void main(String[] args) {
        LocalDateTime localDateTime2 = LocalDateTime.now();
        LocalDateTime localDateTime1 = LocalDateTime.of(2022,4,2,15,24,35);
        LocalDateTime localDateTime3 = LocalDateTime.of(2022,3,21,15,24,35);
        Customer customer = new Customer("smith",101);
        Customer customer1 = new Customer("maly",102);
        Myorder myorder1 = new Myorder(1001,20220402152424222L,98.4,localDateTime1,customer);
        Myorder myorder2 = new Myorder(1002,20220802185024221L,142.1,localDateTime2,customer);
        Myorder myorder3 = new Myorder(1003,20220321155244521L,42.1,localDateTime3,customer);
        Myorder myorder4 = new Myorder(1004,20220321145244521L,42.1,localDateTime3,customer1);
        ArrayList<Myorder> arrayList = new ArrayList<>();
        arrayList.add(myorder1);
        arrayList.add(myorder2);
        arrayList.add(myorder3);
        arrayList.add(myorder4);
        System.out.println(arrayList);

        double sum =0;
        for (Myorder i : arrayList){
            if (i.getCustomer().getCusrName().equals("smith"))
                sum+=i.getOrderPrice();
        }
        System.out.println("订单总价格为"+sum);

        LocalDateTime localDateTime = LocalDateTime.of(2022,5,1,0,0,0);
        for (Myorder i : arrayList){
            if (i.getLocalDateTime().isBefore(localDateTime))
                System.out.println(i);
        }
    }
}
